<template>
	<view class="smart-page">
		<!-- 页面标题头begin-->
		<view class="smart-page-head">
			<view class="smart-page-head-title">audio音频</view>
		</view>
		<!-- 页面标题头end-->
		<view>
			<button type="primary" @click="play()">播放</button>
			<audio id="myaudio" name="我爱你,祖国" controls="true" poster="/static/logo.png" author="贝多芬"
				src="/static/audio/music.mp3"></audio>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		onReady: function() {
			this.audioContext = uni.createAudioContext("myaudio");
		},
		methods: {
			play() {
				this.audioContext.play();
			},
			pause() {
				this.audioContext.pause();
			}
		}
	}
</script>

<style>
	.smart-page-head {
		padding: 20px 0;
		text-align: center;
		margin-bottom: 20px;
	}

	.smart-page-head-title {
		font-size: 24px;
		font-weight: 600;
		color: darkgray;
		display: inline-block;
		position: relative;
		padding-bottom: 8px;
	}

	.smart-page-head-title::after {
		content: '';
		position: absolute;
		left: 0;
		bottom: 0;
		width: 100%;
		height: 2px;
		background-color: lightgray;
	}
</style>